<!--
 * @Author: 瞿旺兴 18774621495@163.com
 * @Date: 2022-05-19 09:47:56
 * @LastEditors: 瞿旺兴 18774621495@163.com
 * @LastEditTime: 2022-06-08 17:33:30
 * @FilePath: \nien-vue3-admin\src\views\finance\receiverManame\reconciliationManagement\Receivable\collectionManage\billing\index.vue
 * @Description: 开票
-->
<template>
  <custom-container ref="customContainerRef" :config="config" />
  <order-detail-dialog ref="orderDetailDialogRef" />
  <invoice-make-dialog ref="invoiceMakeDialogRef" />
</template>
<script setup lang="ts">
import { computed, ref, reactive, defineAsyncComponent } from 'vue'
import { ElButton, ElMessageBox } from 'element-plus'
import { EditPen, QuestionFilled } from '@element-plus/icons-vue'

const orderDetailDialog = defineAsyncComponent(() => import('./components/OrderDetailDialog.vue'))
const invoiceMakeDialog = defineAsyncComponent(() => import('./components/InvoiceMakeDialog.vue'))

const orderDetailDialogRef = ref(null)
const invoiceMakeDialogRef = ref(null)

const multipleSelection = ref([])
const queryParams = reactive({
  pageSize: 10,
  pageNum: 1,
  afterCurrency: undefined,
  exchangeRate: undefined,
  startDate: undefined,
  endDate: undefined,
  remark: undefined,
})
const config = computed({
  get() {
    return {
      query: {
        fields: [
          {
            label: '账单编号',
            prop: 'afterCurrency',
          },
          {
            label: '客户代码',
            prop: 'exchangeRate',
          },
          {
            label: '状态',
            prop: 'remark',
          },
        ],
        queryParams,
        formOption: {},
      },
      btns: [
        {
          title: '开票',
          type: 'primary',
          onClick: (e) => {
            invoiceMakeDialogRef.value.visible = true
          },
        },
      ],
      table: {
        columns: [
          { type: 'selection', width: '55', align: 'center' },
          { type: 'index', width: '55', align: 'center' },
          { label: '账单日期', align: 'center', prop: 'beforeCurrency' },
          { label: '对账单编号', align: 'center', prop: 'afterCurrency' },
          { label: '客户名称', align: 'center', prop: 'exchangeRate' },
          { label: '发票金额', align: 'center', prop: 'startDate' },
          { label: '收款账号', align: 'center', prop: 'startDate' },
          { label: '转入方账号', align: 'center', prop: 'startDate' },
          { label: '纳税人识别号', align: 'center', prop: 'startDate' },
          { label: '地址及电话', align: 'center', prop: 'startDate' },
          { label: '开户行及账号', align: 'center', prop: 'startDate' },
          { label: '邮箱', align: 'center', prop: 'startDate' },
          { label: '状态', align: 'center', prop: 'remark' },
          {
            label: '操作',
            align: 'center',
            width: '200',
            fixed: 'right',
            render(h, params) {
              return [
                h(
                  ElButton,
                  {
                    text: true,
                    type: 'primary',
                    icon: EditPen,
                    onClick: () => {
                      ElMessageBox.confirm('敏感操作，是否继续？', '警告', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning',
                      }).then(() => {
                        console.log(222)
                      })
                    },
                  },
                  {
                    default: () => '推送到客户端',
                  },
                ), 
                h(
                  ElButton,
                  {
                    text: true,
                    type: 'primary',
                    icon: QuestionFilled,
                    onClick: () => {
                      orderDetailDialogRef.value.open(params.row.id)
                    },
                  },
                  {
                    default: () => '开票详情',
                  },
                )]
            },
          },
        ],
        event: {
          onSelectionChange: (rows) => {
            multipleSelection.value = rows
          },
        },
      },
      api: () => Promise.resolve({ code: 200, data: [{ a: 2 }, { b: 2 }] }),
    }
  },
  set(val) {
    return val
  },
})

</script>